<template>
	<view class="content">
		<!-- 报修类型 -->
		<view class="repair_type">
			<view class="type_fl">
				<view>
					<image :src="imgUrl+'/static/wap/infoImg/title@2x.png'"></image>
					<text>报修类型</text>
				</view>
				<view>
					<text>报修编号: {{repairDetails.code}}</text>
				</view>
				<view>
					<text>报修状态: </text>
					<text>{{repairDetails.status | status }}</text>
				</view>
			</view>
			<view class="tyle_fr">
				<image v-if="repairDetails.status == 1 || repairDetails.status == 4" class="tyle_fr_img" :src="imgUrl+'/static/wap/infoImg/daichuli@2x.png'" mode=""></image>
				<image v-if="repairDetails.status == 2" class="tyle_fr_img" :src="imgUrl+'/static/wap/infoImg/chulizhong@2x.png'" mode=""></image>
				<image v-if="repairDetails.status == 3" class="tyle_fr_img" :src="imgUrl+'/static/wap/infoImg/yiwanchneng@2x.png'" mode=""></image>
			</view>
		</view>

		<!-- 详情信息 -->
		<view class="repair_deta">
			<view class="data_item">
				<text class="data_tit">联系方式</text>
				<view class="data_con">
					<text>{{repairDetails.owner}}</text>
					<text>{{repairDetails.mobile}}</text>
				</view>
			</view>

			<view class="data_item">
				<text class="data_tit">报修时间</text>
				<view class="data_con">
					<text>{{repairDetails.create_time}}</text>
				</view>
			</view>

			<view class="data_item">
				<text class="data_tit">报修详情</text>
				<view class="data_con">
					<text> {{repairDetails.content}}</text>
				</view>
			</view>

			<view class="data_item" style="border: none;">
				<text class="data_tit">报修地址</text>
				<view class="data_con">
					<text>{{repairDetails.addr}}</text>
				</view>
			</view>
		</view>

		<!-- 上报信息 -->
		<view class="rep_info" >
		<view v-if="imgArr.length>0">
			<text class="rep_tit">上报图片</text>
			<view >
			<image   :src="v" v-for="v in imgArr"></image>
			</view>
		</view>
			<!-- 取消报修 -->
			<view class="status" v-if="repairDetails.status != 4&&repairDetails.status != 2&&repairDetails.status != 3">
				<text @click="cancelRepair(repairDetails.id)" >取消报修</text>
			</view>
		</view>
	</view>
</template>

<script>
	import util from '../../static/util.js'
	export default {
		data() {
			return {
				imgUrl:util.globalData.imgPre,
				proStatus: ' ',
				repairDetails: '',
				isShowBx: true,
				localImg:[],
				imgArr:[]
			};
		},
		methods: {
			// 取消保修
			cancelRepair(id) {
				let that = this
				that.ajax({
					url: 'api/repair/cancelRepair',
					data: {
						id
					},
					success: function(res) {
						if (res.code == 200) {
							uni.showToast({
								icon: 'none',
								title: res.msg,
								success() {
									setTimeout()
								}
							})
							that.isShowBx = false
						} else {
							uni.showToast({
								icon: 'none',
								title: res.msg
								
							})
						}
					}
				})
			},
			// 详情
			getRepairDetail(id) {
				let that = this
				that.ajax({
					url: 'api/repair/getRepairDetail',
					data: {
						id
					},
					success: function(res) {
						console.log(res)
						if (res.code == 200) {
							that.repairDetails = res.data
							if(res.data.path){
								that.imgArr=res.data.path.split(",")
							}
						}
					}
				})
			}
		},
		// 状态过滤
		filters: {
			status(info) {
				if (info == 1) {
					return '提交'
				} else if (info == 2) {
					return '正在处理'
				} else if (info == 3) {
					return '完成'
				} else {
					return '取消保修'
				}
			}
		},
		onLoad(id) {
			this.getRepairDetail(id.id)
		}
	}
</script>

<style lang="less" scoped>
	.content {
		padding: 20rpx 0;
		font-size: 30rpx;
		letter-spacing: 2rpx;
	}

	.repair_type {
		padding: 0 20rpx 10rpx 20rpx;
		display: flex;
		border-bottom: 20rpx solid #F7F9FB;
		position: relative;
		view {
			flex: 1;
		}

		.type_fl {
			letter-spacing: 2rpx;

			& view:nth-child(1) {
				margin: 40rpx 0;
				height: 53rpx;
				font-weight: 700;

				image {
					margin-right: 33rpx;
					width: 53rpx;
					height: 53rpx;
				}
			}

			& view:nth-child(2) {
				margin-bottom: 40rpx;
				color: #333;
			}

			& view:nth-child(3) {
				color: #333;

				& text:nth-child(2) {
					color: #FB8F24;
				}
			}
		}

		.tyle_fr {
			.tyle_fr_img {
				position: absolute;
				top: 46rpx;
				right: 58rpx;
				width: 170rpx;
				height: 130rpx;
			}
		}
	}

	.repair_deta {
		padding: 0 20rpx;
		letter-spacing: 2rpx;
		border-bottom: 20rpx solid #F7F9FB;
		background-color: #fff;

		.data_item {
			padding-bottom: 20rpx;
			overflow: hidden;
			font-size: 28rpx;
			border-bottom: 2rpx solid #ebebeb;

			.data_tit {
				display: block;
				margin: 30rpx 0;
				color: #999;
			}

			.data_con {
				display: flex;
				justify-content: space-between;
				
				& text:nth-child(2) {
					font-size: 30rpx;
					color: #2AABAD;
				}
			}
		}
	}

	.rep_info {
		padding: 0 20rpx;
		overflow: hidden;

		.rep_tit {
			display: block;
			font-weight: 700;
			margin: 30rpx 0 100rpx 0;
		}

		view {
			image {
				margin-right: 58rpx;
				width: 140rpx;
				height: 140rpx;
			}
		}

		.status {
			margin-top: 130rpx;
			height: 90rpx;
			line-height: 90rpx;
			text-align: center;
			color: #fff;
			font-size: 36rpx;
			border-radius: 45rpx;
			background-color: #2AABAD;
		}
	}
</style>
